-- @owner: lvlintao
-- @date: 2025-11-18
-- @testpoint: D兼容性-在函数中使用测试，成功
@connect PrimaryDbDmode;
--step1 建表指定数据类型;expect:成功
drop table if exists case0007;
create table case0007(col1 int, col2 nvarchar(max), col3 nvarchar(50),
    col4 nvarchar, col5 nvarchar2(max), col6 nvarchar2(50), col7 nvarchar2);
---step2 查看表定义;expect:成功
SELECT
  column_name AS "colname",
  data_type AS "datatype",
  is_nullable AS "isnull",
  column_default AS "default",
  ordinal_position AS "ordinal"
FROM information_schema.columns
WHERE
  table_schema = 'public'
  AND table_name = 'case0007';

--step3 创建函数;expect:成功
drop function if exists func_case0001;
create function func_case0001 returns nvarchar(max) as
$d$
declare
    output1 nvarchar(max);
    output2 nvarchar(max);
    output3 nvarchar(max);
    output4 nvarchar(max);
    output nvarchar(max);
begin
    insert into case0007 values(1, 'abcd', 'abcd', 'a', 'abcd','abcd','a');
    select col2 into output1 from case0007 where col1 = 1;
    raise info 'INFO: output1 is %',output1;
    select col4 into output2 from case0007 where col1 = 1;
    raise info 'INFO: output2 is %',output2;
    select col5 into output3 from case0007 where col1 = 1;
    raise info 'INFO: output3 is %',output3;
    select col7 into output4 from case0007 where col1 = 1;
    raise info 'INFO: output4 is %',output4;
    select output1 || output2 || output3 || output4 into output;
    return output;
END;
$d$ LANGUAGE plpgsql;
/
select func_case0001();

--step4 清理环境;expect:成功
drop function if exists func_case0001;
drop table if exists case0007;




